import {Injectable} from "@angular/core";
import {Http} from "@angular/http";
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/timeout';
import {UrlData} from "../../common/urldata";
import {Observable} from "rxjs/Observable";

@Injectable()
export class HomeService {
  constructor(private http: Http,
              private urlData: UrlData) {
  }

  findArticle(param?: any): Observable<any> {
    return this.http
      .get(this.urlData.baseUrl + `v1/article`, {params: param})
      .timeout(5000)
      .map(res => res.json());
  }

  findRecommendArticle(param?: any): Observable<any> {
    console.log(param);
    return this.http
      .get(this.urlData.baseUrl + `v1/article/recommend`, {params: param})
      .timeout(5000)
      .map(res => res.json());
  }
}
